package com.sas.hnn;

import java.util.Arrays;

import android.app.Activity;
import android.app.ListFragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.AdapterView.OnItemClickListener;

/**
 * Zeigt die Liste an.
 * Nachdem die Liste sortiert wurde, wird der adapter neu gelesen (refresh()).
 * 
 *
 */
public class PersonList extends ListFragment implements OnItemClickListener{
	
	/**
	 * @uml.property  name="tAG"
	 */
	private String TAG= PersonList.class.getSimpleName();
	/**
	 * @uml.property  name="mPersAdapter"
	 * @uml.associationEnd  
	 */
	private PersonAdapter mPersAdapter;
	/**
	 * @uml.property  name="mContext"
	 * @uml.associationEnd  
	 */
	private View mContext;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		mContext= inflater.inflate(R.layout.person_list_row, null);
		refresh();
		//getListView().setOnItemClickListener(this);
		
		
		return super.onCreateView(inflater, container, savedInstanceState);
	}
	
	private void refresh() {
		setListAdapter(mPersAdapter);	
	}

	@Override
	public void onAttach(Activity activity) {
		// TODO Auto-generated method stub
		super.onAttach(activity);
		mPersAdapter= new PersonAdapter(activity);
	}

	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		// TODO Auto-generated method stub
		Log.d(TAG,"press the button"+arg2+","+arg3);
	}
	
	public boolean sort() {
		boolean res= mPersAdapter.sort();
		refresh();
		return res;
	}
	
	public boolean filterAge() {
		boolean res= mPersAdapter.filterAge();
		refresh();
		return res;
	}
	
	
	

}
